"""
@Author  : 康帅
@Time    : 2021/1/23 10:17
@Function: 翻译脚本
@Install: pip install translate
"""

from translate import Translator


class Translate:
    def __init__(self, file):
        self.file = file

    def english_translate_chinese(self):
        """英语翻译中文"""
        translator = Translator(to_lang="chinese")
        translation = translator.translate(self.file)
        return translation

    def chinese_translate_english(self):
        """中文翻译英语"""
        translator = Translator(from_lang="chinese", to_lang="english")
        translation = translator.translate(self.file)
        return translation


if __name__ == '__main__':
    english = Translate("hello")
    chinese = Translate("哈喽")
    print(english.english_translate_chinese())
    print(chinese.chinese_translate_english())
